<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>search article</title>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.js"></script>
<script type="text/javascript">
function Search(){
	this.articleSearchUrl="/wizard/search/article.html";
	this.userSearchUrl="/wizard/search/user.html";
	this.userSearchRefineUrl="/wizard/search/user/refine.html";
	this.searchArticle=function(){
		var articleSearchKey=document.getElementById("articleSearchKey").value;
		if(articleSearchKey&&articleSearchKey!=""){
			var url=this.articleSearchUrl;
			var data="query="+articleSearchKey;
			$.ajax({
				url: url,
				data:data,
				type : "POST",
				dataType:"json",
				contentType: "application/x-www-form-urlencoded; charset=utf-8", 
				success : function(msg){
					alert(msg.data.length);
				}
			});
		}
	};
	this.searchUser=function(){
		var userSearchKey=document.getElementById("searchKey").value;
		if(userSearchKey&&userSearchKey!=""){
			var url=this.userSearchUrl;
			var data="query="+userSearchKey;
			var procUserData=this.procUserData;
			document.getElementById("searchUserDiv").innerHTML="";
			$.ajax({
				url: url,
				data:data,
				type : "POST",
				dataType:"json",
				contentType: "application/x-www-form-urlencoded; charset=utf-8", 
				success : function(msg){
					procUserData(msg.data);
				}
			});
		}
	};
	this.procUserData=function(users){
		var searchUser=document.getElementById("searchUserDiv");
		for(var i=0;i<users.length;i++){
			var user=users[i];
			var innerHTML="";
			innerHTML+="<table>";
			innerHTML+="<tr><td width=\"80px\" rowspan=\"5\"><img src=\"http://localhost:8080/skyline/comment/imagepath/"+user.portrait+".jpg\"></td>";
			innerHTML+="<td>昵称:</td><td>"+user.nickname+"</td></tr>";
			innerHTML+="<td>真实姓名:</td><td>"+user.name+"</td></tr>";
			innerHTML+="<td>E-mail:</td><td>"+user.email+"</td></tr>";
			innerHTML+="<td>来自:</td><td>"+user.province+" "+user.city+"</td></tr>";
			innerHTML+="<td>毕业学校:</td><td>"+user.graduateSchool+"</td></tr></table>";
			searchUser.innerHTML+=innerHTML;
		}
	};
}
var search=new Search();
function getsubsites(selectId,siteId){
	$.ajax({
		url: url,
		data:data,
		type : "POST",
		dataType:"json",
		contentType: "application/x-www-form-urlencoded; charset=utf-8", 
		success : function(msg){
			procUserData(msg.data);
		}
	});
}
</script>
</head>
<body>
<input type="text" name="searchKey" id="searchKey"> <input type="button" onclick="search.searchUser()" value="搜索">
<div id="searchResultDiv">
<div id="searchRefine">
<select id="province" name="province">
</select>
</div>
<div id="searchUserDiv">
</div>
</div>
</body>
</html>